package me.luraframework.db.config;

import me.luraframework.commons.auth.UserContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

import java.util.Optional;


/**
 * @author ranliu
 * @description: JPA 框架配置类
 * @date 11/7/22 12:44 PM
 **/
@Configuration
@EnableJpaAuditing
public class JpaDatabaseConfiguration {

    @Bean
    public AuditorAware<String> auditorAware() {
        return () -> Optional.of(UserContext.currentUsername());
    }


}
